<?php

require "../../vendor/autoload.php";


use B2bic\Commond\Tool;
use B2bic\Request\Account;
use B2bic\Request\AccountList;
use B2bic\Request\AccountMoney;
use B2bic\Request\B2bicRequest;
use B2bic\Request\LedgerSearch;
use B2bic\Enums\Account\AccountOpFlag;

//30206465250015
//30206465100001

// $account = new AccountList();
// $account->setMainAccount('15000100716415');
// // $account->setPageNo('38');
// $account->setReqSubAccountNo('30206465250015');

        $pageNo = 1;
        $start = '20200101000000';
        $end = '20200301000000';

        $account = new LedgerSearch();
        $req = new B2bicRequest();


        $account->setMainAccount('15000100716415');

        $account->setStartTime($start);
        $account->setEndTime($end);
        $account->setPageNo($pageNo);

        // if ($input->hasOption('size')) {
        //     $accountNo =  $input->getOption('size');
        //     $account->setPageSize($accountNo);
        //     $req->setRequestTimes(0);
        // }
        // $account->setOpFlag('1');
        // if ($input->hasOption('account')) {
        //     $accountNo =  $input->getOption('account');
        //     $account->setReqSubAccount($accountNo);
        //     $account->setOpFlag('2');
        //     $req->setRequestTimes(1);
        // }

        $code = date("YmdHis") . rand(1111, 9999);
        $req->setUrl('127.0.0.1:7072')
            ->setCustomerId('00901080000008888000')
            ->setCode($code);
        try {
            var_dump('1111');
            $respons = $req->execute($account,true);
            //返回对应request同名的response
            //获取银行卡号
            if ($respons->responseCode == '000000') {
                $responsAccount = $respons->bodyObject;
                $list = $responsAccount->getList();
                // print_r($list);
                foreach($list as $ac){
                    echo json_encode($ac,JSON_UNESCAPED_UNICODE);
                }
            } else {
                echo '台账查询失败，失败原因';
            }
        } catch (Exception $e) {
            echo $e->getMessage();
        }